/*
 * @Description:
 * @Author: 小雨
 * @Date: 2024-07-02 15:58:30
 * @LastEditTime: 2024-07-04 11:33:37
 * @LastEditors: 小雨
 */

const express = require('express');

const router = express.Router();

const userHandler = require('../router_handler/user');

//导入验证数据的中间件
const expressJoi = require('@escook/express-joi');

//导入规则
const { reg_login_schema } = require('../shema/user');

//声明局部中间件
//验证请求的body是否符合规则并流转到后面路由进行处理
//如果验证失败，终止后面的代码执行，并抛出一个全局的Error错误，进入全局错误级别中间件进行处理
router.post('/reguser', expressJoi(reg_login_schema), userHandler.regUser);

router.post('/login', expressJoi(reg_login_schema), userHandler.login);

module.exports = router;
